﻿using Microsoft.AspNet.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR.Hubs;

namespace Able.Push.Authorization
{
    public class AdminAuthorize : AuthorizeAttribute
    {
        public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
        {
            var name = request.Headers.GetValues("name").FirstOrDefault() ?? string.Empty;
            var pwd = request.Headers.GetValues("pwd").FirstOrDefault() ?? string.Empty;

            if (name == "zr" && pwd == "0d9ccc4ba0")
            {
                return true;
            }
            return false;
        }
    }
}